public class stringTest {
    public static void main(String[] args) {
//        String str = "aabbcc";
//        /* 得到指定下标字符 */
//        char c = str.charAt(2);
//
//        System.out.println(c);
//
//        System.out.println(str.length());


        String s1 = "abc";
        String s2 = "abc";
        String s3 = new String("abc");
        String s4 = new String("abc");

        System.out.println(s1 == s2);
        System.out.println(s1 == s3);
        System.out.println(s2 == s3);

        System.out.println(s1.equals(s2));
        System.out.println(s1.equals(s3));
        System.out.println(s3.equals(s4));

        String s = "123***2345";
        int index = s.indexOf("*");
        int lastIndex = s.lastIndexOf("*");
        System.out.println(index+"   "+lastIndex);

        String ss = "abcdcdefcd";
        String h = ss.replace("cd","*");
        System.out.println(h);

        String p = "qwerty";
        //从指定下标开始，截取指定范围的字串，包含指定开始下标，但是不包含结束下标
        String p1 = p.substring(1,5);
        System.out.println(p1);

        String a = "  aaa  bbb  ";
        //去除字符串首尾的空格，中间不去除
        s.trim();
        System.out.println("*"+s+"*");


    }
}
